package edu.pitt.cs.cs2410pj2.util;

public class TileDistCounter {
	public static int calculateDist(int i, int j, int p) {
		if(i == j) return 0;
		int distance = 0;
		int xi = i/p;
		int yi = i%p;
		int xj = j/p;
		int yj = j%p;
		
		int rowDist = xj-xi;
		int colDist = yj-yi;
		if(rowDist<0) rowDist = 0 - rowDist;
		if(colDist<0) colDist = 0- colDist;
		distance = rowDist+colDist+1;
		return distance;
	}
	
	public static void main(String[] args) {
		System.out.println(calculateDist(0,3,2));
	}
}
